export function IQYCallBack() {
  setTimeout(() => {
    /** 需求整理
     * 自动播放
     * 自动两倍速播放
     * 开启声音
     * 关闭弹幕
     * 关闭广告
     */

    // let currentVideoEl = document.getElementsByTagName("video")[0];
    // currentVideoEl.currentTime = currentVideoEl.duration - 5;
    console.log(
      "%cIQYCallBack.js 13 [`进入了爱奇艺插进`]",
      "color: #43bb88;font-size: 24px;",
      `进入了爱奇艺插进`
    );
    let advertisement = document.getElementsByClassName("cupid-public-time");
    if (advertisement[0] && advertisement[0].style.display === "") {
      console.log("%cIQYCallBack.js 12 []", "color: #43bb88;font-size: 24px;");
      let currentVideoEl = document.getElementsByTagName("video")[0];
      console.log(
        "%cIQYCallBack.js 14 [currentVideoEl.duration - 5]",
        "color: #43bb88;font-size: 24px;",
        currentVideoEl.duration - 5
      );
      for (let i = 0; i < currentVideoEl.duration - 1; i++) {
        console.log("IQYCallBack.js 24", i);
        setTimeout(() => {
          currentVideoEl.currentTime = i;
        }, 10);
      }

      setTimeout(() => {
        currentVideoEl.paused && currentVideoEl.play(); // 自动播放
        currentVideoEl.playbackRate = 2; // 自动两倍速
        currentVideoEl.volume = 1; // 设置百分之百的音量
        currentVideoEl.muted && (currentVideoEl.muted = false); // 关闭静音，开启声音

        let BarrageClass = `qyb-svg qyb-svg-on`;
        let BarrageEl = document.getElementsByClassName(BarrageClass)[0];
        BarrageEl && BarrageEl.click(); // 关闭弹幕
      }, 2000);
    }
  }, 1000);
}
